﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MH.Lib.Serialization
{
    public class SerializerFactory
        : ISerializerFactory
    {
        /// <summary>
        /// Attempts to create a serializer according to given filename
        /// </summary>
        /// <param name="filename"> Filename</param>
        /// <returns> Serializer if successful, null otherwise </returns>
        public ISerializer Create(string filename)
        {
            if (filename.EndsWith(".txt"))
                return new TxtSerializer();

            if (filename.EndsWith(".xml"))
                return new XmlSerializer();

            return null;
        }
    }
}
